package com.trace.app.controller;

import com.trace.app.contract.RecordContractUtil;
import com.trace.app.entity.ProductImg;
import com.trace.app.entity.ResponseResult;
import com.trace.app.service.ProductImgService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (ProductImg)表控制层
 *
 * @author lionkliu
 * @since 2024-04-28 13:35:57
 */
@RestController
@RequestMapping("productImg")
public class ProductImgController {

    @Resource
    private ProductImgService productImgService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {

        return productImgService.selectPage(pageNum, pageSize);
    }

    @GetMapping("/list")
    public ResponseResult list() {
        return ResponseResult.okResult(productImgService.list());
    }

    @GetMapping("{id}")
    public ResponseResult selectOne(@PathVariable Integer id) {
        return productImgService.selectOne(id);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody ProductImg productImg) {
        return productImgService.insertOne(productImg);
    }

    @PutMapping
    public ResponseResult update(@RequestBody ProductImg productImg) {
        return productImgService.updateOne(productImg);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return productImgService.deleteById(id);
    }

}
